package bz.yfw.example.s3blazeds.part2.behavior
{
	import bz.yfw.common.loader.CameraExifLoader;
	import bz.yfw.example.s3blazeds.part2.command.OrientationCommand;
	import bz.yfw.example.s3blazeds.part2.helper.EmpEditCameraHelper;
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Loader;
	import flash.events.Event;
	import flash.events.MediaEvent;
	import flash.geom.Matrix;
	import flash.media.CameraUI;
	import flash.media.MediaPromise;
	import flash.media.MediaType;
	import flash.net.URLRequest;
	
	import jp.shichiseki.exif.ExifInfo;
	
	import org.seasar.akabana.yui.command.core.ICommand;
	import org.seasar.akabana.yui.command.events.CommandEvent;
	import org.seasar.akabana.yui.framework.ns.handler;
	import org.seasar.akabana.yui.framework.ns.helper;

	/**
	 * 社員編集カメラ編集Behavior
	 * @author tokufxug http://twitter.com/tokufxug
	 */ 
	public class EmpEditCameraBehavior
	{
		public var helper:EmpEditCameraHelper;
		public var camera:CameraUI;
		public var exifLoader:CameraExifLoader;
		public var cmd:OrientationCommand;
		
		public function EmpEditCameraBehavior() {
			camera = new CameraUI();
			exifLoader = new CameraExifLoader();
		}
			
		handler function btnShot_click():void {
			camera.launch(MediaType.IMAGE);
		}
		
		handler function camera_complete(event:MediaEvent):void {
			var url:String = event.data.file.url;
			exifLoader.load(new URLRequest(url));
		}
		
		handler function exifLoader_complete(event:Event):void {
			cmd.start(exifLoader);
		}
		
		handler function cmd_complete(event:CommandEvent):void {
			helper.data = event.data as BitmapData;
		}
	}
}